﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="NewPhoto.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Admin.NewPhoto" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <script type="text/javascript" src="../../Content/javascript/jquery.MultiFile.js"></script>
    
    <script type="text/javascript">
    
    $('#multi').MultiFile({
            STRING: {
            remove:'Remove',
            selected:'Selected: $file',
            denied:'Invalid file type $ext!'
            }
        });
        
     $(document).ready(function(){
        
        
        $('img.deleteButton').css('position','relative');
        $('img.deleteButton').css('left',-150);
        if (navigator.appName=="Microsoft Internet Explorer"){
            $('img.deleteButton').css('top',-130);
        }else{
            $('img.deleteButton').css('top',-135);
        }
    });

    
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="StylePlaceHolder" runat="server">
    <style type="text/css">
        .deleteButton a { position: relative; border:none; }
        .deleteButton { position: relative; width:20px; height:20px; border:none; }  
        img.propPhoto{ position:relative; display:inline;  }      
    </style>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <% object vals = new {propertyId = int.Parse(ViewData["PropertyId"].ToString()) };  %>
    <div class="contentDiv" style="margin-left:15%">
        <form method="post" enctype="multipart/form-data" action="<%=  Url.Action("SavePhoto", "Admin", vals ) %>" >
            <% LBRDataContext dc = new LBRDataContext();  %>
            <% RealEstateProperty r = dc.GetRealEstateProperty(int.Parse(ViewData["PropertyId"].ToString())); %>
            <fieldset id="fldRegister" style="width:560px;display:block; text-align:left">
                <legend>New Photo</legend>
                <div style="width:560px; padding-left:10px; height:300px; overflow:auto; position:relative">
                    <% foreach (Photo p in r.Photos.AsEnumerable<Photo>().Where<Photo>(p=>p.Deleted==false))
                       { %>
                       <div style="display:inline; position:relative">
                            <% object pId = new {photoId = p.PhotoId, propertyId = p.RealEstateProperty.PropertyId };  %>
                            <img src='../../Repository/<%= p.FileName %>' alt="" height="150" width="140" style="margin-right:5px; margin-bottom:5px" />
                            <a onclick="return confirm('Delete this photo?');" href='<%=Url.Action("DeletePhotoAndEdit", "Admin", pId ) %>' class="deleteButton"><img title="delete" class="deleteButton" src='../../Content/images/delete.png' alt="delete" /></a>
                            
                       </div>
                       <% } %>
                </div>
            </fieldset>
            <div style="width:560px; margin-top:20px; margin-bottom:20px;">
                <label class="label">Add a photo:</label><input class="multi limit-10 accept-jpg|gif|png" type="file" id="txtImg" name="FName" size="80" />
            </div>
            <div  style="width:560px;">
                <input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
                <button onclick="window.location='../Admin.ashx/EditProperty?propertyId=" + <%= r.PropertyId.ToString() %> + "';return false;">Cancel</button>
            </div>
        </form>
    </div>
</asp:Content>
